﻿#include "Process.h"
#include "Output/Console.h"
#include "Path/Paths.h"
#include "PackagedTask.h"

RProcess::RProcess()
{
    WorkingDirectory=SPaths::GetWorkingDirectory();
    CreatePlatformData();
}

RProcess::~RProcess()
{
    Stop();
    DestroyPlatformData();
}



void RProcess::SetWorkingDirectory(const SPath &InWorkingDirectory)
{
    WorkingDirectory=InWorkingDirectory;

}

SPath RProcess::GetWorkingDirectory() const
{
    return WorkingDirectory;
}


EProcessState RProcess::GetState() const
{
    return State;
}


TVector<uint8_t> RProcess::ReadAllStandardOutput()
{
    return std::move(AllStandardOutput);
}

TVector<uint8_t> RProcess::ReadAllStandardError()
{
    return std::move(AllStandardError);
}

void RProcess::NotifyStandardOutput(TVector<uint8_t> &&Data)
{
    if(Data.Empty())
    {
        return;
    }

    AllStandardOutput.Append(Data);
    OnStandardOutput.Broadcast();
}

void RProcess::NotifyStandardError(TVector<uint8_t> &&Data)
{
    if(Data.Empty())
    {
        return;
    }

    AllStandardError.Append(Data);
    OnStandardError.Broadcast();
}

